package cdu.sl.aichatdemo.service.impl;

import cdu.sl.aichatdemo.mapper.UserMapper;
import cdu.sl.aichatdemo.pojo.entity.User;
import cdu.sl.aichatdemo.service.CustomUserService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
public class CustomUserServiceImpl extends ServiceImpl<UserMapper, User> implements CustomUserService {

    @Override
    public User loadUserByUsername(String email) throws UsernameNotFoundException {
        // 根据邮箱查询用户实体
        LambdaQueryWrapper<User> eq = new LambdaQueryWrapper<User>().eq(User::getEmail, email);
        return baseMapper.selectOne(eq);
    }


}
